<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
 	 <script type="text/javascript" src="${ctx}/js/easyui/jquery-1.8.0.min.js"></script>
 	 
    <link rel="stylesheet" href="${ctx}/css/style.css" type="text/css">
    
	<script src="${ctx}/js/tab.js"></script>
	<script type="text/javascript" src="${ctx}/js/util.js"></script>
	<link rel="stylesheet" href="${ctx}/css/new/admin.css" type="text/css">
	
	
	
    <title>会员查看</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	 <script>
	$(function(){
		var type='${param.memberType}';
    	if(type=='org'){
    		$("#person").remove();
    	}
     	if(type=='person'){
    		$("#org").remove();
    	}
		/** **/
		//初始化数据字典，无论新增或修改
		var dictUrl = "${ctx}/dict/item/list!tree.action";
		DictUtil.getCheckboxList("#memberRoleArray",'memberRoles', dictUrl, {cateEname:"memberType"});
		DictUtil.getRadioList("#memberTypeDiv","memberType", dictUrl, {cateEname:"userType"});//用户类型
		DictUtil.getDictExtList("#strHundredOne", dictUrl, {cateEname:"hyfl"});
		DictUtil.getDictExtList("#enterpriseType", dictUrl, {cateEname:"gslx"});

		
		
		//省市初始化
    	DictUtil.getDictExtList('#province',dictUrl,{cateEname:'area',fatherValue:0})
    	
   		
    	
		
		//如果修改的话，需要传主键。
		var memberId = '${param.memberId}';
		if(memberId!=null && memberId!=""){
			var showMember = '${ctx}/admin/member/selectById.action?memberId='+memberId;
			var showMemberRole = '${ctx}/admin/memberRole/list.action?memberId='+memberId;
			//反显会员信息
			$.ajax({
				type:'post',
				url:showMember,
				//data:$('#'+formname).serialize(),
				dataType:'json',
				success:function(data){
					console.log(data);
				     var member = data.rows;
					 FormUtil.fillData("#add", member, "id");
					 //反显
					 DictUtil.checkRadioDict("strFiftyThree", member.strFiftyThree);
				     DictUtil.checkRadioDict("memberType", '${param.memberType}');
					 DictUtil.checkSelectDict("#province", member.strFiftyFourteen);
					 DictUtil.checkSelectDict("#strHundredOne", member.strHundredOne);
					 DictUtil.checkSelectDict("#enterpriseType", member.enterpriseType);
					 changeCity(member.strFiftyFourteen);
					 DictUtil.checkSelectDict("#city", member.strFiftyThirteen);
					 
				   $(".strHundredTwo").attr("href",member.strHundredTwo);
				   $(".strHundredTwo_img").attr("src",member.strHundredTwo);
				   
				   $(".strHundredThree").attr("href",member.strHundredThree);
				   $(".strHundredThree_img").attr("src",member.strHundredThree);
				}
			});	
			
	
			//反显会员角色
			$.ajax({
				type:'post',
				url:showMemberRole,
				dataType:'json',
				success:function(data){
				     var memberRoles = data.rows;
						var rolesArray = new Array();
				     for(var i=0;i<memberRoles.length;i++){
				    	 var roleEname=memberRoles[i].roleEname;
				    	 rolesArray[i] = roleEname;
				     }
				     
					 DictUtil.checkCheckboxDict("memberRoles", rolesArray);
				}
			});	
			
		}
	})
	
    //省份联动方法
    function changeProvince(fatherValue){
    	changeCity($("#province").val());
    }
    //市联动方法
    function changeCity(fatherValue){
		var dictUrl = "${ctx}/dict/item/list!tree.action";
    	$("#city").empty();
    	DictUtil.getDictExtList('#city',dictUrl,{cateEname:'area',fatherValue:fatherValue})
    }
    function auditDoMember(st){
    	var auditMsg = (st=='91')?"审核通过":"审核不通过";
    	if(!confirm("确实要提交["+auditMsg+"]？")) return;
    	var edUrl = "${ctx}/admin/member/editAuditStatus.action";
    	$.ajax({
		    type:'post',
		    url:edUrl,
		    data:{"memberId":"${param.memberId}","auditStatus":st,"auditMsg":auditMsg},
		    dataType:'json',
		    success: function(myData){
		    	console.log(myData);
		    	if(myData.flag=='T'){
		    		alert(myData.msg);
		    		window.location.href="${ctx}/sendPage/member/member-list";
		    	}else{
		    		alert(myData.msg);
		    	}
		  	}
		});
    }
    function goList(){
    	window.location.href="${ctx}/sendPage/member/member-list";
    }
</script>


  </head>
  
  <body>
   <div id="addDiv" name="addDiv" style="width:95%;margin:0 auto">
   	 <form class="form-horizontal" role="form" method="post" id="add" action="javascript:void(0)">
		<div class="form-group" style="text-align: center;">
					<br/>
		
		
	<c:if test="${param.memberRoles=='addMemberAndRoles' || param.memberRoles=='1'}">
			<jsp:include page="./member-common-view.jsp"></jsp:include>
	</c:if>
	<c:if test="${param.memberRoles=='addExpert'  || param.memberRoles=='2'}">
			<jsp:include page="./member-expert-view.jsp"></jsp:include>
	</c:if>
		
		<c:if  test="${param.flag=='audit'}">
			<br/><br/>
			<button style="font-size: 16px;padding: 5px;font-weight:bold;" onclick="auditDoMember('91');">审核通过 </button>
			&nbsp;&nbsp;&nbsp;&nbsp;
			<button style="font-size: 16px;padding: 5px;font-weight:bold;" onclick="auditDoMember('90');">审核不通过 </button>
		</c:if>
		&nbsp;&nbsp;
		<button style="font-size: 16px;padding: 5px;font-weight:bold;" onclick="goList();">返回 </button>
		</form>	
	</div>			
  </body>
  
  <style>
  	input{border:1px red solid;}
  </style>
 
</html>
